﻿using IntelligentAgriculture.Contracts.Dto.Input;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.AppearanceModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.BodyMeasureModel;
using IntelligentAgriculture.WebAPI.Application.Command.BodyMeasureModelCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace IntelligentAgriculture.WebAPI.Controllers
{
    /// <summary>
    /// 品相测定
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AppearanceModelController : ControllerBase
    {


        private readonly IAppearanceModelService appearanceModelService;
        private readonly TokenService tokenService;
        private readonly ILogger<BreedingWeighController> logger;
        private readonly IMediator mediator;



        /// <summary>
        /// 注入
        /// </summary>
        /// <param name="appearanceModelService"></param>
        /// <param name="tokenService"></param>
        /// <param name="logger"></param>
        /// <param name="mediator"></param>
        public AppearanceModelController(IAppearanceModelService appearanceModelService
          , TokenService tokenService
          , ILogger<BreedingWeighController> logger, IMediator mediator)
        {
            this.appearanceModelService = appearanceModelService;
            this.tokenService = tokenService;
            this.logger = logger;
            this.mediator = mediator;
        }


        /// <summary>
        /// 品相测定列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<PageOutput<AppearanceModelOutPut>>> AppearanceModelList(AppearanceModelnPut? input)
        {
            var command = new AppearanceModelQueryCommand(input);
            var roles = await mediator.Send(command);
            return roles;
        }


        /// <summary>
        /// 品相测定删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DeleteAppearanceModel(params int[] ids)
        {
            var command = new AppearanceModelDeleteCommand(ids.ToArray());
            return await mediator.Send(command);
        }

        /// <summary>
        /// 品相测定添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> AddAppearanceModel(AppearanceModelCreateCommand command)
        {
           return await mediator.Send(command);
        }


        /// <summary>
        /// 品相测定修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> UpdateAppearanceModel(AppearanceModelUpdateCommand command)
        {
            return await mediator.Send(command);
        }





    }




}
